library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.4 v dplyr 1.0.7
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 2.0.1 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(p8105.datasets)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
This plot is a representation of the total number of ordered items per aisle.
data(instacart)
order_aisle_insta =
instacart %>%
group_by(aisle) %>%
summarize(total = n()) %>%
arrange(desc(total)) %>%
filter(total > 10000) %>%
mutate(aisle = fct_reorder(aisle, total)) %>%
plot_ly(x = ~aisle, y = ~total, colors = ~aisle, type = "bar", alpha = 0.5)
ggplotly(order_aisle_insta)
This plot represents a distribution of the hour of day for orders of Pink Lady Apples and Coffee Ice Cream respectively.
order_hour_insta =
instacart %>%
filter(product_name %in% c("Pink Lady Apples", "Coffee Ice Cream")) %>%
group_by(product_name, order_dow) %>%
plot_ly(y = ~order_hour_of_day, color = ~product_name, type = "box", colors = "viridis")
ggplotly(order_hour_insta)
This histogram demonstrates the relationship between order hour and the day for Pink Lady Apples and Coffee Ice Cream respectively.
order_day_insta =
instacart %>%
filter(product_name %in% c("Pink Lady Apples", "Coffee Ice Cream")) %>%
group_by(product_name, order_dow) %>%
plot_ly(x = ~order_hour_of_day, y = ~order_dow, color = ~product_name, type = "histogram")
ggplotly(order_day_insta)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels